package com.olap.starter.service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.olap.starter.core.base.BaseService;
import com.olap.starter.mapper.FormDesignerMapper;
import com.olap.starter.pojo.FormDesigner;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author WBG
 * @since 2023-12-27
 */

@Service
@AllArgsConstructor
@DS("online")
public class FormDesignerServices extends BaseService<FormDesignerMapper, FormDesigner> {

    public List<FormDesigner> findList(String key, Integer limit) {
        LambdaQueryWrapper<FormDesigner> queryWrapper = Wrappers.lambdaQuery(FormDesigner.class);
        queryWrapper.eq(FormDesigner::getDeleted, 0);
        queryWrapper.and(wrapper -> wrapper.like(FormDesigner::getDescription, key).or().like(FormDesigner::getDescCode, key));
        Page<FormDesigner> page = page(new Page<>(1, limit), queryWrapper);
        return page.getRecords();
    }
}
